package com.example.high_widget;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;

import com.example.high_widget.adapter.RecyclerviewAdapter;
import com.example.high_widget.entity.Planet;

import java.util.List;

public class RecyclerviewActivity extends AppCompatActivity {

    private List<Planet> planetList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recyclerview);
        RecyclerView rv_test = findViewById(R.id.rv_test);
        //获取初始化数据
        planetList = Planet.getDefaultList();
        //适配器
        RecyclerviewAdapter recyclerviewAdapter = new RecyclerviewAdapter(this,planetList);
        rv_test.setAdapter(recyclerviewAdapter);
        //设置布局
        rv_test.setLayoutManager(new GridLayoutManager(this,2));
    }
}